//
//  BaseViewController.m
//  RentTable
//
//  Created by mac on 2024/11/29.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@property (nonatomic, strong) UIView *navBackView;

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.hidesBackButton = YES;
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)loadBackArrow {
    
    self.navBackView = [UIView new];
    self.navBackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.navBackView];
    [self.navBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.mas_equalTo(0);
        make.height.mas_equalTo(88 * scaleH);
    }];
    
    UIButton *arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [arrowButton setBackgroundImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [arrowButton addTarget:self action:@selector(arrowButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.navBackView addSubview:arrowButton];
    [arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(44 * scaleH);
        make.leading.mas_equalTo(16);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
}

- (void)loadTitle:(NSString *)title {
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = title;
    nameLabel.font = [UIFont pingFangSCMediumWithSize:16];
    nameLabel.textColor = myRGBHex(0x000000);
    [self.navBackView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(44 * scaleH);
        make.centerX.mas_equalTo(0);
        make.height.mas_equalTo(24);
    }];
}

- (void)loadDevide {
    UIView *devideView = [UIView new];
    devideView.backgroundColor = myRGBHex(0xCCCCCC);
    [self.navBackView addSubview:devideView];
    [devideView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(0);
        make.top.mas_equalTo(88 * scaleH);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)arrowButtonClick {
    [self.navigationController popViewControllerAnimated:true];
}

@end
